package com.study.mq;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class MqUtils {
	private static ConnectionFactory connectionFactory;

	static {
		connectionFactory = new ConnectionFactory();

		connectionFactory.setHost("127.0.0.1");
		//amqp默认端口
		connectionFactory.setPort(5672);
		connectionFactory.setUsername("ems");
		connectionFactory.setPassword("ems");
		//类比于"连库"
		connectionFactory.setVirtualHost("/ems");

	}

	public static Connection getConnection() throws IOException, TimeoutException {
		return connectionFactory.newConnection();
	}
}
